﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:compo="clr-namespace:ReflectionStudio.Controls.Diagram.Components">

    <!--<ContextMenu x:Key="ConnectionContextMenu">
        <MenuItem Header="Delete" Command="{x:Static ApplicationCommands.Delete}">
            <MenuItem.Icon>
                <Image Source="Images/Delete.png" Width="16"/>
            </MenuItem.Icon>
        </MenuItem>
        <Separator/>
        <MenuItem Header="Order">
            <MenuItem Header="Bring Forward" Command="{x:Static s:DesignerCanvas.BringForward}">
                <MenuItem.Icon>
                    <Image Source="Images/BringForward.png" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Bring To Front" Command="{x:Static s:DesignerCanvas.BringToFront}">
                <MenuItem.Icon>
                    <Image Source="Images/BringToFront.png" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Send Backward" Command="{x:Static s:DesignerCanvas.SendBackward}">
                <MenuItem.Icon>
                    <Image Source="Images/SendBackward.png" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Send To Back" Command="{x:Static s:DesignerCanvas.SendToBack}">
                <MenuItem.Icon>
                    <Image Source="Images/SendToBack.png" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
        </MenuItem>
    </ContextMenu>-->

    <Style TargetType="{x:Type compo:Connection}">
        <Style.Resources>
            <!-- Style for the ConnectorAdorner thumbs -->
            <Style x:Key="ConnectionAdornerThumbStyle" TargetType="{x:Type Thumb}">
                <Setter Property="Width" Value="12"/>
                <Setter Property="Height" Value="12"/>
                <Setter Property="SnapsToDevicePixels" Value="true"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <TranslateTransform X="-6" Y="-6"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Thumb}">
                            <Rectangle Fill="#AADCDCDC" Stroke="DodgerBlue" StrokeThickness="1" RadiusX="0" RadiusY="0"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <!-- Arrow Grid Style -->
            <Style x:Key="ArrowGridStyle" TargetType="Grid">
                <Setter Property="Width" Value="10"/>
                <Setter Property="Height" Value="10"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <TranslateTransform X="-5" Y="-5"/>
                    </Setter.Value>
                </Setter>
            </Style>
            <!-- base style for all arrow shapes -->
            <Style x:Key="ArrowSymbolBaseStyle" TargetType="Path">
                <Setter Property="Fill" Value="{DynamicResource NormalBackgroundBrush}"/>
                <Setter Property="Stretch" Value="Fill"/>
            </Style>
            <!-- Arrow -->
            <Style x:Key="Arrow" TargetType="Path" BasedOn="{StaticResource ArrowSymbolBaseStyle}">
                <Setter Property="Data" Value="M0,0 8,4 0,8 Z"/>
            </Style>
            <!-- Diamond  -->
            <Style x:Key="Diamond" TargetType="Path" BasedOn="{StaticResource ArrowSymbolBaseStyle}">
                <Setter Property="Data" Value="M-5,0 0,-5 5,0 0,5 Z"/>
            </Style>
        </Style.Resources>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type compo:Connection}">
                    <Canvas DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=.}"
                            >
                            <!--ContextMenu="{StaticResource ConnectionContextMenu}"-->
                        <Path Name="PART_ConnectionPath"
                              StrokeThickness="2"
                              Stroke="{DynamicResource NormalForegroundBrush}"
                              StrokeStartLineCap="Round"
                              StrokeEndLineCap="Round"
                              StrokeLineJoin="Round"
                              StrokeDashArray="{Binding StrokeDashArray}"
                              SnapsToDevicePixels="True"
                              Data="{Binding PathGeometry}">
                        </Path>
                        <Grid Style="{StaticResource ArrowGridStyle}"
                              Canvas.Left="{Binding AnchorPositionSource.X}"
                              Canvas.Top="{Binding AnchorPositionSource.Y}">
                            <Path Name="PART_SourceAnchorPath"/>
                            <Grid.LayoutTransform>
                                <RotateTransform Angle="{Binding AnchorAngleSource}"/>
                            </Grid.LayoutTransform>
                        </Grid>
                        <Grid Style="{StaticResource ArrowGridStyle}"
                              Canvas.Left="{Binding AnchorPositionSink.X}"
                              Canvas.Top="{Binding AnchorPositionSink.Y}">
                            <Path Name="PART_SinkAnchorPath"/>
                            <Grid.LayoutTransform>
                                <RotateTransform Angle="{Binding AnchorAngleSink}"/>
                            </Grid.LayoutTransform>
                        </Grid>

                        <!--Uncomment this to show default label text-->
                        <!--<TextBlock Width="100" Height="35"
                                       Text="{Binding Path=(Canvas.ZIndex)}"
                                       Canvas.Left="{Binding LabelPosition.X}"
                                       Canvas.Top="{Binding LabelPosition.Y}">
                              <TextBlock.RenderTransform>
                                <TranslateTransform X="5" Y="5"/>
                              </TextBlock.RenderTransform>
                            </TextBlock>-->

                        <Canvas.BitmapEffect>
                            <DropShadowBitmapEffect Color="Gray" Direction="315" ShadowDepth="10" Softness="0" Opacity="0.1"/>
                        </Canvas.BitmapEffect>
                    </Canvas>
                    <ControlTemplate.Triggers>
                        <DataTrigger Value="Arrow" Binding="{Binding RelativeSource={RelativeSource Self},Path=SourceArrowSymbol}">
                            <Setter TargetName="PART_SourceAnchorPath" Property="Style" Value="{StaticResource Arrow}"/>
                        </DataTrigger>
                        <DataTrigger Value="Diamond" Binding="{Binding RelativeSource={RelativeSource Self},Path=SourceArrowSymbol}">
                            <Setter TargetName="PART_SourceAnchorPath" Property="Style" Value="{StaticResource Diamond}"/>
                        </DataTrigger>
                        <DataTrigger Value="Arrow" Binding="{Binding RelativeSource={RelativeSource Self},Path=SinkArrowSymbol}">
                            <Setter TargetName="PART_SinkAnchorPath" Property="Style" Value="{StaticResource Arrow}"/>
                        </DataTrigger>
                        <DataTrigger Value="Diamond" Binding="{Binding RelativeSource={RelativeSource Self},Path=SinkArrowSymbol}">
                            <Setter TargetName="PART_SinkAnchorPath" Property="Style" Value="{StaticResource Diamond}"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
